import pymysql
from fastapi import FastAPI,HTTPException,Form
app=FastAPI()
db={
    "host":"127.0.0.1",
    "user":"root",
    "password":"123456",
    "database":"2304a",
    "charset":"utf8"
}
@app.post('/cx')
def cx(
    employee_name:str=Form(...),
    attendance_date:str=Form(...),
):
    try:
        con=pymysql.connect(**db)
        cursor=con.cursor()
        cursor.execute('select * from attendance where employee_name=%s or attendance_date=%s',(employee_name,attendance_date))
        fis=cursor.fetchone()
        if fis:
            return{
                "a":fis[0],
                "b":fis[1],
                "c":fis[2],
                "d":fis[3]
            }
    finally:
        con.close()
        cursor.close